{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Test Markitdown Library\n",
    "\n",
    "This notebook demonstrates the usage of markitdown library for testing purposes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PDF has been converted to markdown and saved as tt.md\n"
     ]
    }
   ],
   "source": [
    "from autocoder.utils._markitdown import MarkItDown\n",
    "\n",
    "# Initialize MarkItDown converter\n",
    "md_converter = MarkItDown()\n",
    "\n",
    "# PDF file path\n",
    "pdf_file = \"/Users/allwefantasy/projects/mcp-docs/SRE Whitepaper 1.0.5.pdf\"\n",
    "\n",
    "# Convert PDF to markdown\n",
    "result = md_converter.convert(pdf_file)\n",
    "\n",
    "# Save markdown content to file\n",
    "output_file = \"tt.md\"\n",
    "with open(output_file, 'w', encoding='utf-8') as f:\n",
    "    f.write(result.text_content)\n",
    "\n",
    "print(f\"PDF has been converted to markdown and saved as {output_file}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PDF has been converted to markdown and saved as tt2.md\n"
     ]
    }
   ],
   "source": [
    "from autocoder.utils._markitdown import MarkItDown\n",
    "\n",
    "# Initialize MarkItDown converter\n",
    "md_converter = MarkItDown()\n",
    "\n",
    "# PDF file path\n",
    "pdf_file = \"/Users/allwefantasy/Downloads/test-docs/Kyligence_Enterprise_User_Manual-zh.pdf\"\n",
    "\n",
    "# Convert PDF to markdown\n",
    "result = md_converter.convert(pdf_file)\n",
    "\n",
    "# Save markdown content to file\n",
    "output_file = \"tt2.md\"\n",
    "with open(output_file, 'w', encoding='utf-8') as f:\n",
    "    f.write(result.text_content)\n",
    "\n",
    "print(f\"PDF has been converted to markdown and saved as {output_file}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "PDF has been converted to markdown and saved as tt2.md\n"
     ]
    }
   ],
   "source": [
    "from autocoder.utils._markitdown import MarkItDown\n",
    "\n",
    "# Initialize MarkItDown converter\n",
    "md_converter = MarkItDown()\n",
    "\n",
    "# PDF file path\n",
    "pdf_file = \"/Users/allwefantasy/Downloads/副本银联数据大模型报告生成项目_数据解读服务界面用户使用手册_v1.0_241108.docx\"\n",
    "\n",
    "# Convert PDF to markdown\n",
    "result = md_converter.convert(pdf_file)\n",
    "\n",
    "# Save markdown content to file\n",
    "output_file = \"tt2.md\"\n",
    "with open(output_file, 'w', encoding='utf-8') as f:\n",
    "    f.write(result.text_content)\n",
    "\n",
    "print(f\"PDF has been converted to markdown and saved as {output_file}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<mammoth.results.Result at 0x106016560>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import mammoth\n",
    "\n",
    "\n",
    "pdf_file = \"/Users/allwefantasy/Downloads/副本银联数据大模型报告生成项目_数据解读服务界面用户使用手册_v1.0_241108.docx\"\n",
    "\n",
    "result = mammoth.convert_to_html(pdf_file)\n",
    "\n",
    "html_content = result.value\n",
    "\n",
    "with open(\"tt2.html\", 'w', encoding='utf-8') as f:\n",
    "    f.write(html_content)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "byzerllm",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
